*** Settings ***
Resource   ../Common_Head.robot
Library    ExcelLibrary
Library    ArchiveLibrary
 

*** Variables ***


*** Keywords ***
Data Upload Template
    [Arguments]    ${Title}    ${File_Path}
    Wait Until Keyword Succeeds    10x    400ms    Get Page Source    contains    ${Title}    90
    Wait For Elements State   ${Data_toolbar_UploadButton}     enabled
    Click    ${Data_toolbar_UploadButton}
    # Wait Until Keyword Succeeds    120    1    Click    ${Data_toolbar_UploadButton}
    Wait For Elements State    ${Data_Upload_AddFile}    enabled    60
    ${Data_Upload_AddFile1}    Set Variable    xpath=//input[@name='file']
    Upload File By Selector    ${Data_Upload_AddFile1}    ${File_Path}
    Wait For Elements State    xpath=//label[.='Document Name']    visible    30    

Data Upload Template After modified
    [Arguments]    ${Title}    ${File_Path}
    Wait Until Keyword Succeeds    10x    400ms    Get Page Source    contains    ${Title}    90
    Wait For Elements State   ${Data_toolbar_UploadAfterStartButton}     enabled
    Wait Until Keyword Succeeds    30    1    Click    ${Data_toolbar_UploadAfterStartButton}
    Wait For Elements State    ${Data_Upload_AddFile}    enabled    60
    ${Data_Upload_AddFile1}    Set Variable    xpath=//input[@name='file']
    Upload File By Selector    ${Data_Upload_AddFile1}    ${File_Path}
    Wait For Elements State    xpath=//div[@class='row col-md-12 ng-scope']//th[1]/label[@class='info wrappable ']    visible    

Select Location Routing By Location
    [Arguments]    ${PROJECT.MODE}=FCL
    Wait For Elements State   ${Origin_Country}     enabled
    # Select From List By Value    ${Origin_Country}    country from-D
    Wait Until Keyword Succeeds    30    1    Click    ${Origin_Country}
    Repeat Keyword    4    Press Keys    ${Origin_Country}    DOWN
    # Select From List By Value    ${Destination_Country}    country to - G
    Click    ${Destination_Country}
    Repeat Keyword    7    Press Keys    ${Destination_Country}    DOWN
    # Select From List By Value    ${Origin_City}    city from -C
    Click    ${Origin_City}
    Repeat Keyword    3    Press Keys    ${Origin_City}    DOWN
    # Select From List By Value    ${Destination_City}    city to -F
    Click    ${Destination_City}
    Repeat Keyword    6    Press Keys    ${Destination_City}    DOWN
    # Select From List By Value    ${Origin_State}    state from -E
    Click    ${Origin_State}
    Repeat Keyword    5    Press Keys    ${Origin_State}    DOWN
    # Select From List By Value    ${Destination_State}    state to -H
    Click    ${Destination_State}
    Repeat Keyword    8    Press Keys    ${Destination_State}    DOWN
    # Select From List By Value    ${Origin_Type}    origin type -l
    Click    ${Origin_Type}
    Repeat Keyword    9    Press Keys    ${Origin_Type}    DOWN
    # Select From List By Value    ${Destination_Type}    des type -J
    Click    ${Destination_Type}
    Repeat Keyword    10    Press Keys    ${Destination_Type}    DOWN
    # Select From List By Value    ${Origin_Postal_Code}    Origin Postal Code -K
    Click    ${Origin_Postal_Code}
    Repeat Keyword    11    Press Keys    ${Origin_Postal_Code}    DOWN
    # Select From List By Value    ${Destination_Postal_Code}    Destination Postal Code -L
    Click    ${Destination_Postal_Code}
    Repeat Keyword    12    Press Keys    ${Destination_Postal_Code}    DOWN
    # Select From List By Value    ${Customer_Deliver_Term}    Customer’s Delivery Term-M
    Click    ${Customer_Deliver_Term}
    Repeat Keyword    13    Press Keys    ${Customer_Deliver_Term}    DOWN
    # Select From List By Value    ${Customer_Port_of_Load}    Customer Port of Load-N
    Click    ${Customer_Port_of_Load}
    Repeat Keyword    14    Press Keys    ${Customer_Port_of_Load}    DOWN
    # Select From List By Value    ${Customer_Port_of_Discharge}    Customer Port of Discharge-O
    Click    ${Customer_Port_of_Discharge}
    Repeat Keyword    2    Press Keys    ${Customer_Port_of_Discharge}    DOWN
    # Select From List By Value    ${Customer_Lane_ID}    Lane ID code B
    Click    ${Customer_Lane_ID}
    Repeat Keyword    15    Press Keys    ${Customer_Lane_ID}    DOWN
    # Select From List By Value    ${Volume_Containers_20}    Volume Containers 20-P
    Click    ${Volume_Containers_20}
    Repeat Keyword    16    Press Keys    ${Volume_Containers_20}    DOWN
    # Select From List By Value    ${Volume_Containers_40}    Volume Containers 40-Q
    Click    ${Volume_Containers_40}
    Repeat Keyword    17    Press Keys    ${Volume_Containers_40}    DOWN
    # Select From List By Value    ${Volume_Containers_40HC}    Volume Containers 40HC-R
    Click    ${Volume_Containers_40HC}
    Repeat Keyword    18    Press Keys    ${Volume_Containers_40HC}    DOWN
    # Select From List By Value    ${Volume_Containers_45}    Volume Containers 45-S
    Click    ${Volume_Containers_45}
    Repeat Keyword    19    Press Keys    ${Volume_Containers_45}    DOWN
    # Select From List By Value    ${Volume_TEU_Total}    Volume TEU Total-T
    Click    ${Volume_TEU_Total}
    Repeat Keyword    20    Press Keys    ${Volume_TEU_Total}    DOWN
    # Select From List By Value    ${Commodity_Desc}    Commodity Description-U
    Click    ${Commodity_Desc}
    Repeat Keyword    21    Press Keys    ${Commodity_Desc}    DOWN
    # Select From List By Value    ${IMO_Class}    IMO Class-V
    Click    ${IMO_Class}
    Repeat Keyword    22    Press Keys    ${IMO_Class}    DOWN
    # Select From List By Value    ${IMO_UN_No}    IMO UN No.-W
    Click    ${IMO_UN_No}
    Repeat Keyword    23    Press Keys    ${IMO_UN_No}    DOWN


Modify ZIP Excel File
    [Documentation]    Modify the download file(.zip)
    [Arguments]    ${zipFile}    ${Row}    ${Col}    ${Sheet_name}    ${Value}
    ${DOWNLOAD_PATH}     Normalize Path    ${DOWNLOAD_PATH}
    Remove File    ${DOWNLOAD_PATH}${/}*.xlsx
    Extract Zip File    ${zipFile}    ${DOWNLOAD_PATH}
    ${FILES}    List Files In Directory   ${DOWNLOAD_PATH}   *.xlsx
    ${excelFile}     Set Variable    ${DOWNLOAD_PATH}${/}${FILES}[0]
    Open Excel Document    ${excelFile}    ${Sheet_name}
    Write Excel Cell    ${Row}    ${Col}    ${Value}    ${Sheet_name}
    Save Excel Document   ${excelFile}
    Close All Excel Documents
    [Return]    ${excelFile}


    # # archive_should_contain_file ${load_path}Test.zip Test_A.xlsx #判断压缩文件中是否包含Test_A.xlsx
    # # extract_zip_file ${load_path}Test.zip ${load_path} #解压zip
    # # create_zip_from_files_in_directory ${load_path} aa.zip #创建zip文件
    # ${path1}    ${filename1}    Split Path    ${file_path}
    # Extract Zip File    ${zipFile}    ${path1}
    # ${Substring}    Get Substring    ${fileName}    0    -3
    # ${newFilePath}    Set Variable    ${Substring}xlsx
    # ${path}    ${filename}    Split Path    ${newFilePath}
    # Log    ${FILES}
    # Wait Until Keyword Succeeds    50    1    Open Excel Document    ${path}${/}${FILES}[0]    ${Sheet_name}
    # Log    ${path}${/}${FILES}[0]
    # Write Excel Cell    ${Row}    ${Col}    ${Value}    ${Sheet_name}
    # Save Excel Document    ${path}${/}${FILES}[0]
    # Close All Excel Documents
    # [Return]    ${path}${/}${FILES}[0]

Select Location Routing By Location After the Modification
    [Arguments]    ${PROJECT.MODE}=FCL
    Wait For Elements State   ${Origin_Country}     enabled
    # Select From List By Value    ${Origin_Country}    Origin Country - G
    Wait Until Keyword Succeeds    30    1    Click    ${Origin_Country}
    Repeat Keyword    7    Press Keys    ${Origin_Country}    DOWN
    # Select From List By Value    ${Destination_Country}    Destination Country - N
    Click    ${Destination_Country}
    Repeat Keyword    14    Press Keys    ${Destination_Country}    DOWN
    # Select From List By Value    ${Origin_City}    Origin City - H
    Click    ${Origin_City}
    Repeat Keyword    8    Press Keys    ${Origin_City}    DOWN
    # Select From List By Value    ${Destination_City}    Destination City - O
    Click    ${Destination_City}
    Repeat Keyword    15    Press Keys    ${Destination_City}    DOWN
    # Select From List By Value    ${Origin_State}    Origin State - I
    Click    ${Origin_State}
    Repeat Keyword    9    Press Keys    ${Origin_State}    DOWN
    # Select From List By Value    ${Destination_State}    Destination State - P
    Click    ${Destination_State}
    Repeat Keyword    16    Press Keys    ${Destination_State}    DOWN
    # Select From List By Value    ${Origin_Type}    Origin Type - R
    Click    ${Origin_Type}
    Repeat Keyword    10    Press Keys    ${Origin_Type}    DOWN
    # Select From List By Value    ${Destination_Type}    Destination Type - W
    Click    ${Destination_Type}
    Repeat Keyword    17    Press Keys    ${Destination_Type}    DOWN
    # Select From List By Value    ${Origin_Postal_Code}    Origin PostalCode - J
    Click    ${Origin_Postal_Code}
    Repeat Keyword    11    Press Keys    ${Origin_Postal_Code}    DOWN
    # Select From List By Value    ${Destination_Postal_Code}    Destination PostalCode - Q
    Click    ${Destination_Postal_Code}
    Repeat Keyword    18    Press Keys    ${Destination_Postal_Code}    DOWN
    # Select From List By Value    ${Customer_Deliver_Term}    Customer’s Delivery Term - AH
    Click    ${Customer_Deliver_Term}
    Repeat Keyword    12    Press Keys    ${Customer_Deliver_Term}    DOWN
    # Select From List By Value    ${Customer_Port_of_Load}    Customer Port of Load(POL) - X
    Click    ${Customer_Port_of_Load}
    Repeat Keyword    19    Press Keys    ${Customer_Port_of_Load}    DOWN
    # Select From List By Value    ${Customer_Port_of_Discharge}    Customer Port of Discharge(POD) - Y
    Click    ${Customer_Port_of_Discharge}
    Repeat Keyword    13    Press Keys    ${Customer_Port_of_Discharge}    DOWN
    # Select From List By Value    ${Customer_Lane_ID}    Customer Lane Id - C
    Click    ${Customer_Lane_ID}
    Repeat Keyword    20    Press Keys    ${Customer_Lane_ID}    DOWN
    # Select From List By Value    ${Volume_Containers_20}    Volume Containers 20 - Z
    Click    ${Volume_Containers_20}
    Repeat Keyword    14    Press Keys    ${Volume_Containers_20}    DOWN
    # Select From List By Value    ${Volume_Containers_40}    Volume Containers 40 - AA
    Click    ${Volume_Containers_40}
    Repeat Keyword    21    Press Keys    ${Volume_Containers_40}    DOWN
    # Select From List By Value    ${Volume_Containers_40HC}    Volume Containers 40HC - AB
    Click    ${Volume_Containers_40HC}
    Repeat Keyword    15    Press Keys    ${Volume_Containers_40HC}    DOWN
    # Select From List By Value    ${Volume_Containers_45}    Volume Containers 45 - AC
    Click    ${Volume_Containers_45}
    Repeat Keyword    22    Press Keys    ${Volume_Containers_45}    DOWN
    # Select From List By Value    ${Volume_TEU_Total}    Volume TEU Total - AD
    Click    ${Volume_TEU_Total}
    Repeat Keyword    16    Press Keys    ${Volume_TEU_Total}    DOWN
    # Select From List By Value    ${Commodity_Desc}    Commodity Description - AE
    Click    ${Commodity_Desc}
    Repeat Keyword    23    Press Keys    ${Commodity_Desc}    DOWN
    # Select From List By Value    ${IMO_Class}    IMO Class-AF
    Click    ${IMO_Class}
    Repeat Keyword    17    Press Keys    ${IMO_Class}    DOWN
    # Select From List By Value    ${IMO_UN_No}    IMO UN No.-AG
    Click    ${IMO_UN_No}
    Repeat Keyword    24    Press Keys    ${IMO_UN_No}    DOWN

Check modified Excel File
    [Documentation]    Check modified Excel File(.zip)
    [Arguments]    ${zipFile}    ${Row}    ${Col}    ${Sheet_name}    ${Value}
    ${DOWNLOAD_PATH}     Normalize Path    ${DOWNLOAD_PATH}
    Remove File    ${DOWNLOAD_PATH}${/}*.xlsx
    Extract Zip File    ${zipFile}    ${DOWNLOAD_PATH}
    ${FILES}    List Files In Directory   ${DOWNLOAD_PATH}   *.xlsx
    ${excelFile}     Set Variable    ${DOWNLOAD_PATH}${/}${FILES}[0]
    Wait Until Keyword Succeeds    50    1    Open Excel Document    ${excelFile}    ${Sheet_name}
    ${cellValue}    Read Excel Cell    ${Row}    ${Col}    ${Sheet_name}
    Should Be Equal    ${cellValue}    ${Value}
    Close All Excel Documents

Get Download ZIP File Name
    [Documentation]   get download file name if the file name is random,
    ...    argument filenamepattern is file name prefix
    ...    For example, ${fileNanme}    Get Download File Name    AUTO 34959-LCL-Regress_Round*
    [Arguments]    ${fileNamePattern}    ${fileType}=.xlsx
    ${fileName}    Download File    ${Data_toolbar_DownloadButton}
    [Return]    ${fileName}

Check Mapping Columns Checkbox
    [Arguments]    ${RoutingType}=Location
    IF    '${PROJECT.MODE}' == 'FCL'
        Wait Until Keyword Succeeds    100    1    Click    ${Project_DataClean_OriginType}
        Click    ${Project_DataClean_DestinationType}
        Click    ${Project_DataClean_OriginPostalCode}
        Click    ${Project_DataClean_DestinationPostalCode}
        Click    ${Project_DataClean_CustomerDelTerm}
        Click    ${Project_DataClean_CustomerLaneID}
        Click    ${Project_DataClean_Volume20}
        Click    ${Project_DataClean_Volume40}
        Click    ${Project_DataClean_Volume40HC}
        Click    ${Project_DataClean_Volume45}
        Click    ${Project_DataClean_VolumeTEU}
        Click    ${Project_DataClean_CommodityDescription}
        Click    ${Project_DataClean_IMOClass}
        Click    ${Project_DataClean_IMOUNNo}
        IF    '${RoutingType}' == 'Location'
            Click    ${Project_DataClean_CustomerPortofLoad}
            Click    ${Project_DataClean_CustomerPortofDischarge}
        ELSE
            Click    ${Project_DataClean_CustomerOriginPlace}
            Click    ${Project_DataClean_CustomerDestinationPlace}
        END
    END

    IF    '${PROJECT.MODE}' == 'LCL'
        Wait Until Keyword Succeeds    100    1    Click    ${Project_DataClean_OriginType}
        Click    ${Project_DataClean_DestinationType}
        Click    ${Project_DataClean_OriginPostalCode}
        Click    ${Project_DataClean_DestinationPostalCode}
        Click    ${Project_DataClean_CustomerDelTerm}
        Click    ${Project_DataClean_CustomerLaneID}
        Click    ${Project_DataClean_NumberofShipments}
        Click    ${Project_DataClean_WeightinMetric}
        Click    ${Project_DataClean_Volumeincbm}
        Click    ${Project_DataClean_CommodityDescription}
        Click    ${Project_DataClean_IMOClass}
        Click    ${Project_DataClean_IMOUNNo}
        IF    '${RoutingType}' == 'Location'
            Click    ${Project_DataClean_OriginCFS}
            Click    ${Project_DataClean_DestinationCFS}
        ELSE
            Click    ${Project_DataClean_PlaceOrigin}
            Click    ${Project_DataClean_PlaceDestination}
        END
    END

    IF    '${PROJECT.MODE}' == 'AIR'
        Wait Until Keyword Succeeds    100    1    Click    ${Project_DataClean_CustomerServiceLevel}
        Click    ${Project_DataClean_CustomerLaneID}
        Click    ${Project_DataClean_OriginType}
        Click    ${Project_DataClean_DestinationType}
        Click    ${Project_DataClean_OriginPostalCode}
        Click    ${Project_DataClean_DestinationPostalCode}
        Click    ${Project_DataClean_NumberofShipments} 
        Click    ${Project_DataClean_Volumecbm}
        Click    ${Project_DataClean_Actualweight}
        Click    ${Project_DataClean_Chargeableweight}
        Click    ${Project_DataClean_CommodityDescription}
        Click    ${Project_DataClean_CommodityRemarks}
        Click    ${Project_DataClean_DGRClass}
        Click    ${Project_DataClean_DGRUNNo}
        Click    ${Project_DataClean_DGRPAX/CAO}
        Click    ${Project_DataClean_TransitTimeDtoA}
        Click    ${Project_DataClean_TransitTimeAtoA}
        Click    ${Project_DataClean_TransitTimeAtoD}
        Click    ${Project_DataClean_TransitTimeDtoD}
        IF    '${RoutingType}' == 'Location'
            Click    ${Project_DataClean_CustomerOriginAirport}
            Click    ${Project_DataClean_CustomerDestinationAirport}
        ELSE
            Click    ${Project_DataClean_CustomerOriginPlace}
            Click    ${Project_DataClean_CustomerDestinationPlace}
        END
        
    END


Air Select Location Routing
    [Arguments]    ${RoutingType}=Location
    Wait Until Search Finished
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    contains    visible    
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    not contains    disabled    
    Sleep    2
    # ${list}    Get List Items    ${Origin_Country}
    Wait Until Keyword Succeeds    20x    100ms    Select Options By   ${Origin_Country}      label    ${SPACE}${SPACE}country from - F    Country from - F
    Select Options By   ${Destination_Country}      label    ${SPACE}${SPACE}country to - I    Country to - I
    Select Options By   ${Origin_State}      label    State from - G    State From - G
    Select Options By   ${Destination_State}      label    State To - J
    Select Options By   ${DB_Schenker_Service_Level}      label    Schenker Service Level - C
    Select Options By   ${Customer_Service_Level}      label    TSP - Transport Service Provider - B
    Select Options By   ${MD/LD}      label    MD/LD - K
    Select Options By   ${Air_Customer_Lane_ID}      label    Lane ID code - D
        IF    '${RoutingType}' == 'Location'
            Select Options By   ${Origin_City}      label    ${SPACE}city from - E
            Select Options By   ${Destination_City}      label    ${SPACE}${SPACE}city to - H
            Select Options By   ${Air_Origin_Type}    label    Origin Type - P
            Select Options By   ${Air_Destination_Type}    label    Des Type - Q
            Select Options By   ${Air_Origin_Postal_Code}    label    Origin Postal Code - R
            Select Options By   ${Air_Destination_Postal_Code}    label    Destination Postal Code - S
            Select Options By   ${Customer_Origin_Airport}    label    Customer Origin Airport - T
            Select Options By   ${Customer_Destination_Airport}    label    Customer Destination Airport - U
            Select Options By   ${Number_of_Shipments}    label    Number of Shippments - V
            Select Options By   ${Volume_cbm}    label    Volume(cbm) - W
            Select Options By   ${Actual_Weight_in_Kg}    label    Actual weight in kg - X
            Select Options By   ${Chargeable_Weight_in_Kg}    label    Chargeable weight in kg - Y
            Select Options By   ${Air_Commodity_Desc}    label    Commodity Description - Z
            Select Options By   ${Commodity_Remarks}    label    Commodity Remarks - AA
            Select Options By   ${DGR_Class}    label    DGR Class - AB
            Select Options By   ${DGR_UN_No}    label    DGR UN No. - AC
            Select Options By   ${DGR_PAX/CAO}    label    DGR PAX/CAO. - AD
            Select Options By   ${Transit_Time_DTA_inHours}      label    Transit Time Door to Airport in hours - L
            Select Options By   ${Transit_Time_ATA_inHours}      label    Transit Time Airport to Airport in hours - M
            Select Options By   ${Transit_Time_ATD_inHours}      label    Transit Time Airport to Door in hours - N
            Select Options By   ${Transit_Time_DTD_inHours}      label    Transit Time Door to Door in hours - O
        ELSE   
            Select Options By   ${Origin_Port}      label    Customer Origin Airport - P
            Select Options By   ${Destination_Port}      label    Customer Destination Airport - Q
            Select Options By   ${Air_Origin_Type}    label    Origin Type - L
            Select Options By   ${Air_Destination_Type}    label    Des Type - M
            Select Options By   ${Air_Origin_Postal_Code}    label    Origin Postal Code - N
            Select Options By   ${Air_Destination_Postal_Code}    label    Destination Postal Code - O
            Select Options By   ${Customer_Origin_Place}    label    ${SPACE}city from - E
            Select Options By   ${AirCustomer_Destination_Place}    label    ${SPACE}${SPACE}city to - H
            Select Options By   ${Number_of_Shipments}    label    Number of Shippments - R
            Select Options By   ${Volume_cbm}    label    Volume(cbm) - S
            Select Options By   ${Actual_Weight_in_Kg}    label    Actual weight in kg - T
            Select Options By   ${Chargeable_Weight_in_Kg}    label    Chargeable weight in kg - U
            Select Options By   ${Air_Commodity_Desc}    label    Commodity Description - V
            Select Options By   ${Commodity_Remarks}    label    Commodity Remarks - W
            Select Options By   ${DGR_Class}    label    DGR Class - X
            Select Options By   ${DGR_UN_No}    label    DGR UN No. - Y
            Select Options By   ${DGR_PAX/CAO}    label    DGR PAX/CAO. - Z
            Select Options By   ${Transit_Time_DTA_inHours}      label    Transit Time Door to Airport in hours - AA
            Select Options By   ${Transit_Time_ATA_inHours}      label    Transit Time Airport to Airport in hours - AB
            Select Options By   ${Transit_Time_ATD_inHours}      label    Transit Time Airport to Door in hours - AC
            Select Options By   ${Transit_Time_DTD_inHours}      label    Transit Time Door to Door in hours - AD
        END


LCL Select Location Routing
    [Arguments]    ${RoutingType}=Location
    Wait Until Search Finished
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    contains    visible    
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    not contains    disabled
    Sleep    2
    # ${list}    Get List Items    ${Origin_Country}
    # log    ${list}
    Wait Until Keyword Succeeds    20x    100ms    Select Options By   ${Origin_Type}      label    origin type - I
    Select Options By   ${Destination_Type}      label    des type - J
    Select Options By   ${Origin_Postal_Code}      label    Origin Postal Code - K
    Select Options By   ${Destination_Postal_Code}      label    Destination Postal Code - L
    Select Options By   ${LCL_Customer_Lane_ID}      label    Lane ID code - B
    Select Options By   ${LCL_Customer_Deliver_Term}      label    Customer's\nDelivery\nTerm - M
    Select Options By   ${LCL_Number_of_Shipments}      label    number of shipments - P
    Select Options By   ${LCL_Weight_in_Metric_Tons}      label    weight in Metrics tons - Q
    Select Options By   ${LCL_Volume_in_cbm}      label    volumn in cbm - R
    Select Options By    ${LCL_Commodity_Desc}    label    commodity description - S
    Select Options By   ${LCL_IMO_Class}    label    IMO Class - T
    Select Options By   ${LCL_IMO_UN_No}     label    IMO UN No. - U
        IF    '${RoutingType}' == 'Location'
            Select Options By   ${Origin_Country}      label    ${SPACE}${SPACE}country from - D
            Select Options By   ${Destination_Country}     label    ${SPACE}${SPACE}country to - G
            Select Options By   ${Origin_City}    label    ${SPACE}city from - C
            Select Options By   ${Destination_City}    label    ${SPACE}${SPACE}city to - F
            Select Options By   ${Origin_State}    label    State From - E
            Select Options By   ${Destination_State}    label    State To - H
            Select Options By   ${Origin_CFS}    label    Customer CFS origin - N
            Select Options By   ${Destination_CFS}    label    Customer CFS Des - O
        ELSE   
            Select Options By   ${Origin_Country}      label    ${SPACE}${SPACE}country from - C
            Select Options By   ${Destination_Country}      label    ${SPACE}${SPACE}country to - E
            Select Options By   ${Origin_Port}    label    origin port - N
            Select Options By   ${Destination_Port}    label    destination port - O
            Select Options By   ${Origin_State}    label    State From - D
            Select Options By   ${Destination_State}    label    State To - F
            Select Options By   ${LCL_Place_Origin}    label    place origin - G
            Select Options By   ${LCL_Place_Dest}    label    place des - H
        END

FCL Select Location Routing
    [Arguments]    ${RoutingType}=Location
    Wait Until Search Finished
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    contains    visible    
    Wait Until Keyword Succeeds   20x    500ms    Get Element States    ${Origin_Country}    not contains    disabled
    Sleep    2
    # ${list}    Get List Items    ${Origin_Country}
    Wait Until Keyword Succeeds    20x    100ms    Select Options By   ${Origin_Country}      label    ${SPACE}${SPACE}country from - D
    Select Options By   ${Destination_Country}      label    ${SPACE}${SPACE}country to - G
    Select Options By   ${Origin_State}      label    State From - E
    Select Options By   ${Destination_State}      label    State To - H
        IF    '${RoutingType}' == 'Location'
            Select Options By   ${Origin_City}      label    ${SPACE}city from - C
            Select Options By   ${Destination_City}      label    ${SPACE}${SPACE}city to - F
            Select Options By   ${Origin_Type}    label    origin type - I
            Select Options By   ${Destination_Type}    label    des type - J
            Select Options By   ${Origin_Postal_Code}    label    Origin Postal Code - K
            Select Options By   ${Destination_Postal_Code}    label    Destination Postal Code - L
            Select Options By   ${Customer_Deliver_Term}    label    Customer's\nDelivery\nTerm - M
            Select Options By   ${Customer_Port_of_Load}    label    Customer Port of Load - N
            Select Options By   ${Customer_Port_of_Discharge}    label    Customer Port of Discharge - O
            Select Options By   ${Customer_Lane_ID}    label    Lane ID code - B
            Select Options By   ${Volume_Containers_20}    label    Volume\nContainers\n20 - P
            Select Options By   ${Volume_Containers_40}    label    Volume\nContainers\n40 - Q
            Select Options By   ${Volume_Containers_40HC}    label    Volume\nContainers\n40HC - R
            Select Options By   ${Volume_Containers_45}    label    Volume Containers 45 - S
            Select Options By   ${Volume_TEU_Total}    label    Volume\nTEU\nTota - T
            Select Options By   ${Commodity_Desc}    label    Commodity\nDescription - U
            Select Options By   ${IMO_Class}    label    IMO Class - V
            Select Options By   ${IMO_UN_No}      label    IMO UN No. - W
        ELSE   
            Select Options By   ${Origin_Port}      label    ${SPACE}origin port - C
            Select Options By   ${Destination_Port}     label    ${SPACE}destination port - F
            Select Options By   ${Origin_Type}    label    origin type - K
            Select Options By   ${Destination_Type}    label    des type - L
            Select Options By   ${Origin_Postal_Code}    label    Origin Postal Code - M
            Select Options By   ${Destination_Postal_Code}    label    Destination Postal Code - N
            Select Options By   ${Customer_Deliver_Term}    label    Customer's\nDelivery\nTerm - O
            Select Options By   ${Customer_Orign_Place}    label    customer origin place - I
            Select Options By   ${Customer_Destination_Place}    label    customer des place - J
            Select Options By   ${Customer_Lane_ID}    label    Lane ID code - B
            Select Options By   ${Volume_Containers_20}    label    Volume\nContainers\n20 - R
            Select Options By   ${Volume_Containers_40}    label    Volume\nContainers\n40 - S
            Select Options By   ${Volume_Containers_40HC}    label    Volume\nContainers\n40HC - T
            Select Options By   ${Volume_Containers_45}    label    Volume Containers 45 - U
            Select Options By   ${Volume_TEU_Total}    label    Volume\nTEU\nTota - V
            Select Options By   ${Commodity_Desc}    label    Commodity\nDescription - W
            Select Options By   ${IMO_Class}    label    IMO Class - X
            Select Options By   ${IMO_UN_No}      label    IMO UN No. - Y
        END
    
Check Check Box for Routing
    ${count}    Get Element Count    //legend[contains(.,"Step2: Mapping Columns")]/following-sibling::div/div//input[@type="checkbox" ]
    ${end}    Evaluate    int(${count}+1)
    FOR    ${index}    IN RANGE    1    ${end}    1
        Log    ${index}
        ${status}    Run Keyword And Return Status    Get Element States    (//legend[contains(.,"Step2: Mapping Columns")]/following-sibling::div/div//input[@type="checkbox" ])[${index}]    contains    unchecked
        IF    '${status}' == 'True'
            Click    (//legend[contains(.,"Step2: Mapping Columns")]/following-sibling::div/div//input[@type="checkbox" ])[${index}]
        END   
    END

Check All Check Box for Dialog
    [Arguments]    ${legend}
    Wait Until Search Finished
    Wait Until Search Finished
    ${Tabindex}    Set Variable        1
    ${checkboxindex}    Set Variable        1
    ${uncheckedbox}    Set Variable    //legend[contains(.,"${legend}")]/following-sibling::div/div//input[@type="checkbox"][contains(@class, 'ng-empty')]
    ${TabName}    Set Variable    //legend[contains(.,"${legend}")]/following-sibling::div/div//li/a[@class='ng-binding']
    ${count}    Get Element Count    ${uncheckedbox}
    # ${count}    Set Variable    10
    ${TabCount}    Get Element Count    ${TabName}
    ${end}    Evaluate    int(${count}+1)
    # ${TabEnd}    Evaluate    int(${TabCount}+1)
    FOR    ${index}    IN RANGE    1    ${end}    1
        Log    ${index}
        ${originalcount}    Get Element Count    ${uncheckedbox}
        ${status}    Run Keyword And Return Status    Get Element States    (${uncheckedbox})[${checkboxindex}]    contains    visible
        IF    '${status}' == 'True'
            Click    (${uncheckedbox})[${checkboxindex}]
            ${currentcount}    Get Element Count    ${uncheckedbox}
            IF    ${currentcount} == ${originalcount}
                ${checkboxindex}    Evaluate    int(${checkboxindex}+1)
            END
        ELSE
            ${Tabindex}    Evaluate    int(${Tabindex}+1)
            IF    ${TabCount} < ${Tabindex}
                Exit For Loop
            END
            Log    ${Tabindex}
            Click    (${TabName})[${Tabindex}]
            ${originalcount}    Get Element Count    ${uncheckedbox}
            ${visibleStatus}    Run Keyword And Return Status    Get Element States    (${uncheckedbox})[${checkboxindex}]    contains    visible
            IF    '${visibleStatus}' == 'True'
                    Click    (${uncheckedbox})[${checkboxindex}]
                    ${currentcount}    Get Element Count    ${uncheckedbox}
                    IF    ${currentcount} == ${originalcount}
                         ${checkboxindex}    Evaluate    int(${checkboxindex}+1)
                    END
            END
        END
        ${currentcount}    Get Element Count    ${uncheckedbox}
    END

Uncheck ALL TBN Checkbox
    [Arguments]    ${legend}    ${Tabindex}=1
    ${checkboxindex}    Set Variable        1
    ${TBNCheckbox}    Set Variable    //input[@placeholder='TBN']/../../../input[@type='checkbox'][contains(@class, 'ng-not-empty')]
    ${TBNcount}    Get Element Count    ${TBNCheckbox}
    ${TabName}    Set Variable    //legend[contains(.,"${legend}")]/following-sibling::div/div//li/a[@class='ng-binding']
    ${TabCount}    Get Element Count    ${TabName}
    ${end}    Evaluate    int(${TBNcount}+1)
    Click    (${TabName})[${Tabindex}]
    FOR    ${index}    IN RANGE    1    ${end}    1
        Log    ${index}
        ${currentcount}    Get Element Count    ${TBNCheckbox}
        ${status}    Run Keyword And Return Status    Get Element States    (${TBNCheckbox})[1]    contains    visible
        IF    '${status}' == 'True'
            Click    (${TBNCheckbox})[1]
            ${currentcount}    Evaluate    int(${currentcount}-1)
        ELSE
            ${Tabindex}    Evaluate    int(${Tabindex}+1)
            IF    ${TabCount} < ${Tabindex}
                Exit For Loop
            END
            Click    (${TabName})[${Tabindex}]
            ${visibleStatus}    Run Keyword And Return Status    Get Element States    (${TBNCheckbox})[1]    contains    visible
            IF    '${visibleStatus}' == 'True'
                    Click    (${TBNCheckbox})[1]
                    ${currentcount}    Evaluate    int(${currentcount}-1)
            END
        END
        IF    ${currentcount} == 0
                Exit For Loop
        END
    END

    ${TBNcount}    Get Element Count    ${TBNCheckbox}
    IF    ${TBNcount} > 0
        Uncheck ALL TBN Checkbox    ${legend}    ${Tabindex}
    END



Read Excel cell by row index and Column Value
    [Arguments]    ${row}    ${col}    ${sheet}
    ${headers}    Read Excel Row    1    0    sheet_name=${sheet}
    Log    ${headers}
    Log    ${col}
    ${index}    Get Index From List    ${headers}    ${col}
    ${col}    Evaluate    int(${index+1})
    ${cellValue}    Read Excel Cell    ${row}    ${col}    ${sheet}
    [Return]    ${cellValue}

